﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Thor.SharePoint2007.WebServices
{
    public static class DateTimeExtensions
    {
        public static string ToSharePointString(this DateTime source)
        {
            //YYYY-MM-DDTHH:MM:SSZ"

            StringBuilder result = new StringBuilder();

            result.Append(source.Year.ToString());
            result.Append("-");
            result.Append(source.Month.ToString("00"));
            result.Append("-");
            result.Append(source.Day.ToString("00"));
            result.Append("T");
            result.Append(source.Hour.ToString("00"));
            result.Append(":");
            result.Append(source.Minute.ToString("00"));
            result.Append(":");
            result.Append(source.Second.ToString("00"));
            result.Append("Z");

            return result.ToString();
        }
    }
}
